angular.module('admin.resetPw', ['ui.router', 'auth'])
    .config(function ($stateProvider) {
        $stateProvider.state('admin.resetPw', {
            url: '/resetPw',
            templateUrl: 'app/admin/resetPw/resetPw.html',
            controller:'resetPwCtrl'
        })
    })
    .controller('resetPwCtrl', function($scope, $http, $log, hash) {
        $scope.resetPw = function() {
            if($scope.password != $scope.confirmPw) {
                $scope.flag = '密码输入不一致';
            }
            else {
                var postUrl = 'http://115.159.71.32:20161/ecust-apis/admin-dangerous/account-password';
                var postData = {
                    uid:$scope.username,
                    pwd:hash($scope.username, $scope.password)
                }
                $log.debug(postData);
                var promise = $http.post(postUrl, postData);
                promise.then(function(res) {
                    $log.debug(res);
                })
            }
        }
    })